<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <!-- vue中的遍历需要用到 v-for 指令 ；并且在使用时，一定要注意加上key值 -->
    <!-- key值的作用为记录遍历对象的状态，使得在遍历时保持对象在遍历前所保持的状态 -->
    <div class="box">
        <ul>
            <li v-for='item in arr1'>{{item}}</li>
        </ul>
        <div v-for='(item,index) in arr2' :key='item.id'>
            id：{{item.id}}, 姓名：{{item.name}},年龄：{{item.age}}
        </div>
    </div>
    <script>
        let vm = new Vue({
            el: '.box',
            data: {
                arr1: ['hehe', 'haha', 'heihei', 'xixi'],
                arr2: [{
                    id: 1,
                    name: 'zhangsan',
                    age: 20
                }, {
                    id: 2,
                    name: '李四',
                    age: 20
                }, {
                    id: 3,
                    name: '王五',
                    age: 20
                }, {
                    id: 4,
                    name: '赵六',
                    age: 20
                }]
            }
        })
    </script>
</body>

</html>